{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**环境：Win10，Mysql8.0**\n",
    "\n",
    "## 1. [下载路径](https://dev.mysql.com/downloads/mysql/)\n",
    "\n",
    "## 2. [安装教程](https://blog.csdn.net/qq_34531925/article/details/78022905) \n",
    "\n",
    "为方便起见，建议将 C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin 目录添加到 path 环境变量下。      \n",
    "\n",
    "---\n",
    "\n",
    "接下来有一个问题，data 默认安装到了 C 盘。随着数据库越来越大，这会导致 C 盘非常卡。**本文接下来，示例将数据库 data 移到 D 盘：**\n",
    "\n",
    "## 3. 创建文件夹\n",
    "\n",
    "  在D:\\下新建 MysqlData 文件夹\n",
    "\n",
    "## 4. 查看现在的data文件存放位置\n",
    "\n",
    "从开始菜单打开`Mysql8.0 Command Line Client` 或者 从cmd输入以下命令进入mysql命令行\n",
    "\n",
    "```sh\n",
    "mysql -u root -p\n",
    "然后输入密码，进入 mysql\n",
    "```\n",
    "\n",
    "进入 mysql 之后，通过如下命令查看 data 默认存储路径：\n",
    "\n",
    "```sql\n",
    "show variables like '%dir%';\n",
    "```\n",
    "\n",
    "如下所示：\n",
    "可以看到我现在的数据存储路径是 `C:\\ProgramData\\MySQL\\MySQL Server 8.0\\Data`\n",
    "\n",
    "![](https://md-picture-1254350681.cos.ap-beijing.myqcloud.com/20201202102559.png)\n",
    "\n",
    "\n",
    "## 5. 停止Mysql 服务\n",
    "\n",
    "通过管理员身份进入cmd控制台，输入: \n",
    "\n",
    "```sh\n",
    "net stop mysql80\n",
    "```\n",
    "\n",
    "或者通过其他方式关闭服务都行\n",
    "\n",
    "## 6. 迁移Data目录\n",
    "\n",
    "将上面的`C:\\ProgramData\\MySQL\\MySQL Server 8.0\\Data` 路径下的所有文件**移动**到你刚创建的新的目录下\n",
    "\n",
    "\n",
    "## 7. 修改 data 路径\n",
    "\n",
    " 关闭 mysql 服务之后，修改 my.ini 文件。这个文件属于隐藏文件，需要去打开隐藏文件名。一般，my.ini 在这个路径下（`C:\\ProgramData\\MySQL\\MySQL Server 8.0\\my.ini`）。你可以直接复制该路径，`Win + R，粘贴、回车`一气呵成,即可打开该文件\n",
    "\n",
    "将 my.ini 文件的一个配置 改为：`datadir=D:/MysqlData`（`datadir=D:/MysqlData` 为上面创建的新存储路径， 注意斜杠不要反了）\n",
    "\n",
    "## 7. 开启 mysql 服务\n",
    "\n",
    "```\n",
    "net start mysql80\n",
    "```\n",
    "\n",
    "大功告成"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "212.2px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
